'use strict';
let Response = require('../../../model/Response');
let RestifyProxy = require('../../../util/RestifyProxy');
let CustomPageBean = require('../../../model/CustomPageBean');
let logsService = require('../../../service/logs-center/logsService');
let logger = require('../../../util/LoggerUtil').logger('logsController.js');

/**
 * 日志中心——运行日志页面
 */
module.exports.runPage = function () {
    let response = new Response();
    response.render('back/logs-center/run');
    this.resolve(response);
};
/*
* 日志中心——运行日志类型
* */
module.exports.runType = async function () {
    let req = this.req;
    let params = req.body;
    let response = new Response();
    try {
        let result = await logsService.runType(this, params);
        response.send(result);
    } catch (error) {
        logger.error(error);
    }
    this.resolve(response);
};
/**
 * 日志中心——运行日志列表
 */
module.exports.runList  = async function () {
    let req = this.req;
    let params = req.body;
    let response = new Response();
    try {
        let result = await logsService.runList(this, params);
        let pageBean = new CustomPageBean(result);
        response.send(pageBean);
    } catch (error) {
        logger.error(error);
    }
    this.resolve(response);
};
/**
 * 日志中心——运行日志——清理按钮
 */
module.exports.runClear = async function () {
    let req = this.req;
    let params = req.body;
    let response = new Response();
    try {
        let result = await logsService.runClear(this, params.logId);
        response.send(result);
    } catch (error) {
        logger.error(error);
    }
    this.resolve(response);
};

/**
 * 日志中心——操作日志页面
 */
module.exports.operatePage = function () {
    let response = new Response();
    response.render('back/logs-center/operate');
    this.resolve(response);
};
/*
 * 日志中心——操作日志类型
 * */
module.exports.operateType = async function () {
    let req = this.req;
    let params = req.body;
    let response = new Response();
    try {
        let result = await logsService.operateType(this, params);
        response.send(result);
    } catch (error) {
        logger.error(error);
    }
    this.resolve(response);
};
/**
 * 日志中心——操作日志页面列表
 */
module.exports.operateList  = async function () {
    let req = this.req;
    let params = req.body;
    let response = new Response();
    try {
        let result = await logsService.operateList(this, params);
        let pageBean = new CustomPageBean(result);
        response.send(pageBean);
    } catch (error) {
        logger.error(error);
    }
    this.resolve(response);
};
/**
 * 日志中心——操作日志——清理按钮
 */
module.exports.operateClear = async function () {
    let req = this.req;
    let params = req.body;
    let response = new Response();
    try {
        let result = await logsService.operateClear(this, params.logId);
        response.send(result);
    } catch (error) {
        logger.error(error);
    }
    this.resolve(response);
};